typedef struct {{ c_code.struct_name }}
{
    {% set max_length = ((registers | map(attribute='name') | map('length') | max) + 
                         (registers | map(attribute='type') | map('length') | max) +
                         (registers | map(attribute='size') | map('string') | map('length') | max) + 4) -%}
    {%- if registers | selectattr('code_atomic', 'defined') | selectattr('code_atomic', 'equalto', true) | list | length > 0 -%}
        {%- set max_length = max_length + 8 -%}
        {%- set atomci_length = 8 -%}
    {%- else -%}
        {%- set atomci_length = 0 -%}
    {%- endif -%}
    {% set max_address_length = ((registers | map(attribute='address') | map('string') | map('length') | max)) -%}
    {% for register in registers %}
    {%- if register.details or register.enum %}
    /*
    {%- endif -%}

    {%- if register.enum %}
     * Data value reference (数据取值参考) -> {{ register.enum }}
    {%- endif %}
    {%- if register.details %}
    {%- for line in register.details.splitlines() %}
     * {{ line }}
    {%- endfor -%}
    {%- endif -%}

    {%- if register.details or register.enum %}
     */
    {%- endif %}
    /* {{ register.privilage }} *//* {{ register.address }} */
    {#- 寄存器类型定义 -#}
    {%- if register.class == "input_coil" or register.class == "holding_coil" -%}
    {{' ' * (max_address_length - (register.address | string | length) + 1)}}uint16_t {% else -%}
    {{' ' * (max_address_length - (register.address | string | length) + 1)}}
        {%- if register.code_atomic -%}
        _Atomic {{ register.type }} {% else -%}
        {%- if register.type == "uint16_t(bits)" or register.type == "uint32_t(bits)" -%}
        {{ register.struct }} {% else -%} 
        {{ register.type }} {% endif -%} {% endif -%}
    {%- endif -%}
    {#- 寄存器名称定义 -#}
    {%- if register.type == "int16_t" or register.type == "int32_t" %} {% endif -%}
    {{ register.name }}
    {%- if register.class == "input_coil" or register.class == "holding_coil" -%}
    : {{ register.size }};
    {%- else -%}
    {%- if register.size > 1 -%}
    [{{ register.size }}];
    {%- else -%}
    ;
    {%- endif -%}
    {%- endif -%}
    {#- 注释定义 -#}
    {%- if register.description -%}
        {%- if register.size > 1 and (register.class != "input_coil" and register.class != "holding_coil") -%}
            {{ ' ' * (max_length - (register.name | length) - (register.size | string | length) - atomci_length - 2)}}
        {%- else -%}
            {%- if register.class == "input_coil" or register.class == "holding_coil" -%}
                {{ ' ' * (max_length - (register.name | length) - (register.size | string | length) - 2)}}
            {%- else -%}
                {%- if register.type == "int16_t" or register.type == "int32_t" -%}
                {{ ' ' * (max_length - (register.name | length) - atomci_length)}}
                {%- else -%}
                {{ ' ' * (max_length - (register.name | length) - atomci_length)}}
                {%- endif -%}
            {%- endif -%}{#- end of if register.class == "input_coil" or register.class == "holding_coil" -#}
        {%- endif -%}
        /* {% for line in register.description.splitlines() %}{{ line }}{%- endfor %} */
    {%- endif -%}{#- end of register.description -#}
    {%- if register.details or register.enum %}
    {% endif -%}
    {% endfor %}{#- end of {% for register in registers %} #}
} {{ c_code.struct_name }}, *{{ c_code.struct_ptr_prefix }}{{ c_code.struct_name }}{{ c_code.struct_ptr_suffix }};
